using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    [SerializeField] private float moveSpeed;
    [SerializeField] private float jumpForce;
    private float xInput;

    private Rigidbody2D rb;
    private AbilityMode abilityMode;

    Ability ability;
    private void Start()
    {
        rb= GetComponent<Rigidbody2D>();
        abilityMode=GetComponent<AbilityMode>();
    }

    private void Update()
    {
        xInput=Input.GetAxis("Horizontal");
        rb.velocity=new Vector2 (xInput*moveSpeed,rb.velocity.y );

        if(Input.GetKeyDown(KeyCode.Escape))
        {
            abilityMode.AddAbility(AbilityManager.instance.GetAbility(0));
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            rb.velocity=new(rb.velocity.x,jumpForce);
            abilityMode.OnKillEnemyAbility();

        }
    }

}
